Skip to content

Conversation

skirpichev
Copy link
Contributor

@skirpichev skirpichev commented Sep 12, 2025

This value indicating support the IEC 60559 floating-point standard (the Annex F of C99). If enabled, the float type characteristics matches the IEC 60559 double format and exceptional cases for the math's functions follow to the section F.10 of the C99 standard.


📚 Documentation preview 📚: https://cpython-previews--138811.org.readthedocs.build/

https://cpython-previews--138811.org.readthedocs.build/en/138811/library/sys.html#sys.float_info
https://cpython-previews--138811.org.readthedocs.build/en/138811/library/math.html#math.nan

This value indicating support the IEC 60559 floating-point standard (the
Annex F of C99).  If enabled, the float type characteristics matches the
IEC 60559 double format and exceptional cases for the math's functions
follow to the section F.10 of the C99 standard.
@picnixz
Copy link
Member

picnixz commented Sep 13, 2025

I think it would be better if the field was in uppercase but I don't know if we have many other cases like that.

@skirpichev
Copy link
Contributor Author

I think it would be better if the field was in uppercase

This will be inconsistent wrt the rest (other field names are also come from macros).

@skirpichev skirpichev requested a review from vstinner September 13, 2025 12:59
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Co-authored-by: Victor Stinner <[email protected]>
@skirpichev
Copy link
Contributor Author

I'm thinking if it does make sense to mention this flag in cmath docs.

We could say that:

  1. Functions selection mostly follows to the Annex G.6 section (modulo conversions and classifications functions). Currently we just mention that functions set is different wrt the math module.
  2. Functions behavior follows to the Annex G.6 in exceptional cases (well, with some exceptions, see gh-133895: correct values of cmath.cosh/sinh in case of overflows #135603, which aren't user-visible right now), if sys.float_info.stdc_iec_559 is true.

@vstinner
Copy link
Member

@picnixz @serhiy-storchaka: What do you think of this change?

@serhiy-storchaka
Copy link
Member

I am not sure what is the best place for this constant. What do @mdickinson and @tim-one think about this? Other options are discussed in the issue.

@picnixz
Copy link
Member

picnixz commented Sep 17, 2025

I'm not really comfortable with float_info but I don't really know whether a module-wide constant is better. I would be more comfortable with a new struct, say stdc_info or features_info which contains other feature for the C standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants